package com.wyz.web;

import com.wyz.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/delStuById")
public class DeleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String id = req.getParameter("id");
        StudentService ss = new StudentService();
        boolean flag = ss.delStu(id);
        if (flag){
//            如果删除成功 跳转删除后表的样子
            req.getRequestDispatcher("studentAll").forward(req,resp);
        }else {
            PrintWriter pw = resp.getWriter();
            pw.println("删除失败");
        }
    }
}
